#ifndef CTCPNETWORK_H
#define CTCPNETWORK_H

#include <QObject>
#include <QTcpServer>
#include <QFile>
#include <QStringList>

#include "../Models/MStaticData.h"
#include "../Models/MTcpNetwork.h"
#include "../Models/MCharacter.h"
#include "../Models/MDataMap.h"

class CTcpNetwork : public QObject
{
    Q_OBJECT
    private:
        MTcpNetwork* m_network;
        QTcpServer *server;

        CTcpNetwork();
        ~CTcpNetwork();

        static CTcpNetwork *singleton;
        static CTcpNetwork *singleton_chat;
        static CTcpNetwork *singleton_gs;

    public:
        static CTcpNetwork *get_instance();
        static CTcpNetwork *get_instance_chat();
        static CTcpNetwork *get_instance_gs();

        MTcpNetwork* get_network();

        void get_map();

    signals:
        void is_receiving();
        void is_disconnecting();

        void authentification_ok();
        void authentification_failed();

        void receive_chat(QString);

        void receive_characters(QTcpSocket*);

        void new_character(QTcpSocket*);

        void sync(QTcpSocket*, int, int, int);

        void leave(int);

        void player_join(MCharacter*);
        void player_leave(int);
        void player_sync(QTcpSocket*, int,int,int);

        void bomb_sync(int, int);

        void map_recover();

    public slots:
        void connect(QString hostaname, quint16 port);
        void disconnect();

        void select_action();
        void select_action(QTcpSocket* socket);

        void send(QString message);
        void send(QTcpSocket* socket, QString message);
        QString receive();
        void receive_map();
        QString receive(QTcpSocket* socket);
};

#endif // CTCPNETWORK_H
